<template>
  <div class="detailPage">
    <div class="bigbox" v-if="typelist">
      <!-- 头部 -->
      <header>
        <div class="h-left">
          <div @click="back">
            <img src="../../assets/image/18721.png" style="width: 8px" />
          </div>
        </div>
        <div class="h-title">书架详情</div>
        <div class="h-right" style="margin-right: 10px">
          <router-link to="/personal">书架</router-link>
        </div>
      </header>

      <!-- 书籍具体 -->
      <div class="book_specific">
        <div class="book_top">
          <div class="book_img">
            <img :src="typelist.novelImg + '?param=140y140'" alt="" />
          </div>
          <!-- 介绍 -->
          <div class="infour">
            <div class="in_textone">
              <h1>{{ typelist.novelTitle }}</h1>
            </div>
            <div class="in_texttwo">{{ typelist.Author }}</div>
            <div class="in_texttwo">
              {{ typelist.state }}(共{{ typelist.Serial }}章)
            </div>
          </div>
          <!-- 收藏 -->

          <span
            :class="color == true ? 'coll' : ''"
            class="iconfont icon-lolxiai collection"
            
          ></span>
        </div>
        <!-- 阅读 -->
        <div class="reading">
          <router-link to="/novelmain" class="reading_btn"
            ><span>免费阅读</span></router-link
          >
        </div>
        <!-- 章节 -->
        <div class="new-book">
          <div class="latest">最新</div>
          <div class="chapter">
            <router-link to="/directory"
              >第二章怪物</router-link
            >
          </div>
          <div class="time_hoe">{{ typelist.Day }}</div>
        </div>
      </div>
      <!-- 简介 -->
      <div class="mulu_lists">
        <div class="catalog">
          <div id="one1" class="active">简介</div>
          <div id="one2">目录</div>
        </div>
        <div id="con_one_1">
          <div class="janjie">
            <div class="synopsis">{{ typelist.Synopsis }}</div>
            <div class="migu">{{ typelist.Authorization }}</div>
          </div>
        </div>
      </div>

      <!-- 页脚 -->
      <footermodule></footermodule>
    </div>
  </div>
</template>

<script>
import { getTypeList } from "../../api/home.js";

import footermodule from "../../components/FooterModule.vue";
// import { Toast } from "vant";

export default {
  data() {
    return {
      typelist: null,

      color: false, //收藏后改变图标颜色
      shoucangList: [],
    };
  },
  methods: {
    //   返回上一步
    back() {
      this.$router.go(-1);
    },

    getTypeListFun() {
      getTypeList({ id: this.$route.query.id }).then((data) => {
        // console.log(data);
        let index = data.typelist.findIndex(
          (item) => item.novelId == this.$route.query.id
        );
        this.typelist = data.typelist[index];
        let num = 0;
        this.shoucangList.forEach((item) => {
          if (item.novelId == this.typelist.novelId) {
            num++;
          } else {
            return num;
          }
        });
        if (num != 0) {
          this.color = true;
        }
      });
    },
  },
  created() {
    if (localStorage.shoucang) {
      this.shoucangList = JSON.parse(localStorage.getItem("shoucang2"));
    }
    console.log(this.$route.query);
    if ("id" in this.$route.query) {
      this.getTypeListFun();
    }
  },
  components: {
    footermodule,
  },
};
</script>

<style lang="scss" scoped>
.book_specific {
  background-color: #fff;
}
.book_top {
  padding: 15px 10px 15px 10px;
  display: flex;
  position: relative;
}
.book_img {
  width: 80px;
  height: 100px;
  background-color: aqua;
  position: relative;
  img {
    width: 100%;
    height: 100%;
    box-shadow: 3px 3px 7px #8888885e;
  }
  &:before {
    content: "";
    display: block;
    position: absolute;
    top: 0px;
    left: 0px;
    width: 30px;
    height: 30px;
    background: url("../../assets/image/15559.png") no-repeat center;
    background-size: 30px 30px;
  }
}
.infour {
  -webkit-box-flex: 1;
  margin-left: 10px;
  padding-top: 4px;
}
.in_textone {
  padding-right: 15px;
  & > h1 {
    font-size: 16px;
    color: #2e343f;
    padding-bottom: 8px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding-top: 1px;
    font-weight: normal;
  }
}
.in_texttwo {
  font-size: 12px;
  color: #666;
  padding-bottom: 8px;
  margin-top: 5px;
}
/* 收藏 */
.collection {
  position: absolute;
  right: 25px;
  top: 20px;
  color: #999;
}
.coll {
  color: rgb(221, 59, 59);
}
/* 阅读 */
.reading {
  margin: 0px 12px;
  display: flex;
  justify-content: center;
}
.reading_btn {
  display: block;
  height: 32px;
  border: 1px #aaaaaa solid;
  border-radius: 3px;
  text-align: center;
  width: 130px;
  margin: 0px 8px;
  span {
    font-size: 15px;
    color: #555;
    line-height: 32px;
    background: url("../../assets/image/阅读.png") left center no-repeat;
    background-size: 14px 13px;
    padding-left: 20px;
  }
}
.down_btn {
  background: #d3270f;
  height: 34px;
  border-radius: 3px;
  text-align: center;
  -webkit-box-flex: 1;
  margin: 0px 8px;
  span {
    font-size: 15px;
    color: #fff;
    line-height: 34px;
    background: url("../../assets/image/down.png") left center no-repeat;
    background-size: 14px;
    padding-left: 20px;
  }
}
/* 章节 */
.new-book {
  height: 40px;
  border-top: 1px #efefef solid;
  margin-top: 15px;
  display: -webkit-box;
  line-height: 40px;
}
.latest {
  width: 38px;
  height: 18px;
  background-color: #8bc118;
  border-radius: 0 3px 3px 0;
  margin-top: 12px;
  line-height: 18px;
  text-align: center;
  font-size: 12px;
  color: #fff;
}
.chapter {
  width: 66%;
  font-family: "微软雅黑";
  font-size: 14px;
  margin-left: 5px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.time_hoe {
  position: absolute;
  right: 10px;
  font-size: 10px;
  color: #9f9f9f;
}
/* 简介 */
.mulu_lists {
  background: #fff;
  margin-top: 10px;
  padding-top: 10px;
  padding-bottom: 1px;
}
.catalog {
  display: -webkit-box;
  height: 35px;
  border-left: 1px solid #b8b8b8;
  margin-bottom: 10px;
  border-top: 1px solid #b8b8b8;
  border-bottom: 1px solid #b8b8b8;
  margin-right: 20px;
  margin-left: 20px;
  background-color: #ededed;
  & > div {
    -webkit-box-flex: 1;
    text-align: center;
    font-size: 15px;
    color: #666666;
    line-height: 35px;
    border-right: 1px #b8b8b8 solid;
  }
  .active {
    color: #ff0020;
    background-color: #fff;
  }
}
.janjie {
  margin-right: 20px;
  margin-left: 20px;
  font-size: 12px;
  line-height: 23px;
  padding-bottom: 10px;
  .synopsis {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }
}
.migu {
  font-size: 10px;
  color: #9f9f9f;
  line-height: 24px;
}
/* 页脚 */
.footer {
  position: relative;
  .bac-top {
    position: fixed;
    top: 80%;
    right: 15px;
    width: 75px;
    height: 75px;
    background-size: 100%;
  }
}
</style>